SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE FUNCTION live.TMPTvf()
RETURNS	 TABLE	 
AS 
RETURN 
--;WITH cte AS (
	SELECT  ai.AssetId
			, ai.InstrumentId
			, ai.PortfolioId
			, ai.LotId
		  , LTRIM(RTRIM(ai.PortfolioId ))+ '-' + CAST(ai.InstrumentId AS VARCHAR(10))  AS ART_InstRoll
		  , ssr.ClientFund + '-' + ssr.CUSIP AS SSB_InstRoll	
	      , ssr.StateStreetIdentifier
	      , ssr.SecurityDescription
	      , ssr.CUSIP
	      , ssr.LotNumber
	      , ssr.TradeDate
	      , ssr.ActualSettlementDate
	      , ssr.AssetClass
	      , ssr.BaseMarketValue
	      , ssr.BaseOriginalCost
	      , ssr.SharesParValue
	      , ssr.BaseUnrealizedGainLoss
	      , ssr.AmortizedCostBase
	      , ssr.AmortizedCostLocal
	      , ssr.ClientFund
	      , ssr.AccountNumber
	       FROM FSFundModel.dbo.AssetIdentifier AS ai
	RIGHT JOIN  FSFundModel.dbo.StateStreetRecon ssr 
	ON ai.AssetId = ssr.StateStreetIdentifier
	WHERE ssr.ImportId = (SELECT MAX(i.ImportId) FROM  FSFundModel.dbo.Import i WHERE i.FundId = 'FSIC')
	--)
GO
EXEC sp_addextendedproperty N'VirtualFolder', N'Live', 'SCHEMA', N'Live', 'FUNCTION', N'TMPTvf', NULL, NULL
GO
